/*
 * ========THE SOLMIX PROJECT=====================================
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.gnu.org/licenses/ 
 * or see the FSF site: http://www.fsf.org. 
 */

package org.solmix.fmk.pool;

import org.apache.commons.pool.impl.GenericObjectPool.Config;
import org.solmix.SLXConstants;
import org.solmix.commons.logs.Logger;
import org.solmix.commons.util.DataUtil;
import org.solmix.fmk.config.ConfigRealm;

/**
 * configuration of poolableObject
 * 
 * @version $Id$
 */
public class SlxObjectPoolConfig extends Config
{

   private static final String FILTER = SLXConstants.SERVICE_CM_NAME + "=" + SLXConstants.MODULE_DS_NAME;

   private static Logger log = new Logger( SlxObjectPoolConfig.class.getName() );

   // @Inject
   // @Reference(id = "ds-config", serviceInterface = ConfigRealm.class, timeout = 100, filter = FILTER)
   private ConfigRealm configRealm;

   /**
    * @return the configRealm
    */
   public ConfigRealm getConfigRealm()
   {
      return configRealm;
   }

   /**
    * @param configRealm the configRealm to set
    */
   public void setConfigRealm( ConfigRealm configRealm )
   {
      this.configRealm = configRealm;
   }

   public SlxObjectPoolConfig()
   {
      try
      {
         DataUtil.setProperties( configRealm.getSubtree( "pooling.default" ), this );
      } catch ( Exception e )
      {
         log.error( "Problem initializing default pool parameters." );
      }
   }
}
